Q: What will be the output of the following JavaScript code? var string1 = ”123”; var intvalue = 123; alert( string1 + intvalue );
Solution: In JavaScript the alert function does the type casting and converts the integer value to string. After that it concatenates both the strings and shows the result as a concatenated string. Thus 123123 would be correct.
Q: A function definition expression can be called as __________
Solution: A function definition expression is a “function literal” in the same way that an object initializer is an “object literal.” A Function definition expression typically consists of the keyword function followed by a comma-separated list of zero or more identifiers (the parameter names) in parentheses and a block of JavaScript code (the function body) in curly braces.
Q: The property of a primary expression is ____________
Solution: The simplest expressions, known as primary expressions, are those that stand alone — they do not include any simpler expressions. Primary expressions in JavaScript are constant or literal values, certain language keywords, and variable references.
Q: Consider the following JavaScript statements. var text = "testing: 1, 2, 3"; // Sample text var pattern = /d+/g // Matches all instances of one or more digits In order to check if the pattern matches with the string “text”, the statement is ____________
Solution: The given pattern is applied on the text given in the parenthesis.
Q: The expression of calling (or executing) a function or method in JavaScript is called ________
Solution: An invocation expression is JavaScript’s syntax for calling (or executing) a function or method). It starts with a function expression that identifies the function to be called.
Q: What kind of expression is “new Point(2,3)”?
Solution: An object creation expression creates a new object and invokes a function (called a constructor) to initialize the properties of that object. Object creation expressions are like invocation expressions except that they are prefixed with the keyword new.
Q: Which of the operator is used to test if a particular property exists or not?
Solution: The operator “in” tests whether a particular property exists or not. In operator is usually added in looping statements to traverse the array or the object.
Q: Among the following, which one is a ternary operator?
Solution: JavaScript supports one ternary operator, the conditional operator ?:, which combines three expressions into a single expression. If else case can be replaced by the conditional operator
Q: “An expression that can legally appear on the left side of an assignment expression.” is a well known explanation for variables, properties of objects, and elements of arrays. They are called ___________
Solution: lvalue is a historical term that means “an expression that can legally appear on the left side of an assignment expression.” In JavaScript, variables, properties of objects, and elements of arrays are lvalues.
Q: What will be the equivalent output of the following JavaScript code snippet? x = ~-y; w = x = y = z; q = a?b:c?d:e?f:g;
Solution: Brackets have higher precedence than any other operator. The placement of brackets results in the same result as without putting any bracket.
You Have Score    | /10 |